import { format_with_array, strToFixed } from './index'

export function amountFormat(row, column) {
	if (row instanceof Object) {
		let keys = column.property.split('.')
		if (keys.length == 2) {
			return format_with_array(strToFixed(row[keys[0]][keys[1]], 2))
		} else {
			return format_with_array(strToFixed(row[keys[0]], 2))
		}
	} else {
		return format_with_array(strToFixed(row, 2))
	}
}

export function priceFormat(row, column) {
	if (row instanceof Object) {
		let keys = column.property.split('.')
		if (keys.length == 2) {
			return format_with_array(strToFixed(row[keys[0]][keys[1]], 4))
		} else {
			return format_with_array(strToFixed(row[keys[0]], 4))
		}
	} else {
		return format_with_array(strToFixed(row, 4))
	}
}

export function quantityFormat(row, column) {
	if (row instanceof Object) {
		let keys = column.property.split('.')
		if (keys.length == 2) {
			return format_with_array(strToFixed(row[keys[0]][keys[1]], 3))
		} else {
			return format_with_array(strToFixed(row[keys[0]], 3))
		}
	} else {
		return format_with_array(strToFixed(row, 3))
	}
}
